Skip to content

Python: Support Declarative Spec for OpenAIAssistantAgent & OpenAIResponsesAgent #12247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 26, 2025

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

This PR builds on the initial work/abstractions from #11982. The AzureAssistantAgent / OpenAIAssistantAgent as well as the AzureResponsesAgent / OpenAIResponsesAgent now support declarative specs. Several examples on how to declare the spec are shown in the respective dirs in samples/concepts/agents, as well as a simple getting started example for each agent type.

To further simplify working with these two agents, the setup_resources() methods for each agent type have been marked with a deprecation tag. The new method to use is OpenAIAssistantAgent.create_client() or OpenAIResponsesAgent.create_client(). Further, when one needs to access the underlying setting's, it's simple to do so with a settings object and accessing the attribute.

In the previous PR for the AzureAIAgent, it lacked support for templating - this is included in this current PR.

Description

Bring in support for the declarative single agent spec for these agent types.

Contribution Checklist

@moonbox3 moonbox3 self-assigned this May 23, 2025
@moonbox3 moonbox3 requested a review from a team as a code owner May 23, 2025 02:59
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel documentation labels May 23, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented May 23, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
__init__.py40100% 
agents
   __init__.py10280%60, 64
   agent.py3364985%122, 129, 142–143, 146–148, 151–153, 204, 209, 214, 219, 224, 228, 232, 236, 277–279, 307–308, 310, 314, 434, 436, 501, 515, 571, 573, 598, 612, 625, 677, 684–685, 688–689, 708, 755, 812, 897–898, 900–901, 955, 1016, 1031
agents/azure_ai
   azure_ai_agent.py35217051%98, 100–103, 105–107, 109–114, 116, 118, 120–122, 124, 141–143, 145–146, 151–152, 157–160, 165–169, 171–174, 176–182, 187, 189–192, 194–196, 198–201, 203, 205, 215–216, 218–221, 223–224, 229, 231–237, 239, 272, 283–284, 289–290, 293, 298–303, 310–311, 313, 318–319, 330–336, 388, 390, 396, 407, 410, 412, 414, 416, 450, 481–483, 485, 487–488, 490–493, 495–496, 499, 502–511, 513, 522–523, 526–528, 530–531, 541–542, 544, 562, 564, 567, 569–570, 572–573, 575, 584–585, 587, 589–592, 595, 597, 600–602, 606, 675, 781, 885, 958
agents/channels
   open_ai_assistant_channel.py570100% 
agents/open_ai
   assistant_thread_actions.py3385683%107, 110, 116, 195, 197, 236–242, 416, 474, 500, 599–600, 602–603, 609–610, 612–613, 615–618, 620–621, 623–624, 626–627, 641–645, 648–650, 697, 699–700, 704–708, 710–711, 725–726, 797, 802, 834
   azure_assistant_agent.py892571%34, 104, 108, 174–175, 185–186, 188, 194, 197–198, 202–207, 209–210, 212–213, 215, 245, 265, 275
   azure_responses_agent.py916132%38, 91–92, 102–103, 105, 111, 114–115, 119–124, 126–127, 129–130, 132, 142, 181–182, 192–193, 195, 201, 204–205, 209–214, 216–217, 219–220, 222, 241, 243, 246, 248–249, 251–252, 254, 264–265, 267, 269–272, 275, 277, 280–282, 286
   openai_assistant_agent.py3606980%74, 110–113, 118, 122–123, 156, 173–174, 182–187, 194–195, 198, 203–204, 215–221, 399–400, 407–408, 410–411, 413–414, 416–421, 423, 470, 473, 476–485, 487, 497, 521–522, 560, 576, 586, 602, 615, 651, 795, 904, 1011
   openai_responses_agent.py40710274%65, 94, 113–116, 124, 128–129, 161–165, 169, 174, 179, 184, 190, 195–196, 199, 202, 207–212, 217–218, 220–221, 227–230, 236, 238–239, 243–247, 338, 342, 346, 348, 354, 367, 369, 371, 375, 470–471, 478–479, 481–482, 484–485, 487–492, 494, 541, 586, 602, 612, 646, 654, 657, 661, 663, 666, 689, 692–696, 706, 746, 771, 782, 873, 993, 1034, 1036, 1110, 1150–1151, 1153–1157, 1176
   responses_agent_thread_actions.py34310768%167, 184, 195, 206–207, 374–376, 390, 395, 402, 420–421, 425, 469–471, 474, 492–493, 502–504, 508, 512–513, 517–519, 530–532, 554, 556–557, 564–565, 567–568, 570, 572–573, 575–576, 659–661, 673–674, 676–680, 682–688, 690–699, 701–702, 704–707, 714–716, 721, 723, 782–785, 826–827, 831–833, 835, 860–861, 863–867, 869, 879–880, 888, 892, 899, 905, 969
TOTAL26991456883% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3616 18 💤 0 ❌ 0 🔥 1m 56s ⏱️

@moonbox3 moonbox3 added this pull request to the merge queue May 26, 2025
Merged via the queue into microsoft:main with commit ff19970 May 26, 2025
28 checks passed
@moonbox3 moonbox3 deleted the assistant-declarative-agent branch May 26, 2025 05:10
@github-project-automation github-project-automation bot moved this to Sprint: Done in Semantic Kernel May 26, 2025
eavanvalkenburg pushed a commit that referenced this pull request May 26, 2025
…ponsesAgent (#12247)

This PR builds on the initial work/abstractions from #11982. The
`AzureAssistantAgent` / `OpenAIAssistantAgent` as well as the
`AzureResponsesAgent` / `OpenAIResponsesAgent` now support declarative
specs. Several examples on how to declare the spec are shown in the
respective dirs in `samples/concepts/agents`, as well as a simple
getting started example for each agent type.

To further simplify working with these two agents, the
`setup_resources()` methods for each agent type have been marked with a
deprecation tag. The new method to use is
`OpenAIAssistantAgent.create_client()` or
`OpenAIResponsesAgent.create_client()`. Further, when one needs to
access the underlying setting's, it's simple to do so with a settings
object and accessing the attribute.

In the previous PR for the AzureAIAgent, it lacked support for
templating - this is included in this current PR.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Bring in support for the declarative single agent spec for these agent
types.
- Add samples
- Add unit tests
- Add support for prompt templates for all current agent types
- Closes #11979

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents documentation python Pull requests for the Python Semantic Kernel
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Python: Support Declarative Agent Spec for OpenAIAssistantAgent & OpenAIResponsesAgent
4 participants